home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Development Platforms / Apple II / Apple II Sample Code / MPW IIGS SC / SC.020.DTS.Tools.Libs / fakeModalDialog.usage < prev    next >
Encoding:
Text File  |  1990-03-22  |  4.1 KB  |  93 lines  |  [TEXT/MPS ]

  1. There are a lot of ways to use fakeModalDialog, and therefore there is a lot
  2. to know.  However, for simple cases, using fakeModalDialog is very simple.
  3. In complex cases, using fakeModalDialog is still a lot simpler than if it were
  4. not used.  Overall, using fakeModalDialog makes dialog things a lot easier to
  5. do than before.
  6.  
  7. How to use fakeModalDialog in a simple case:
  8.  
  9. Step 1:  Open a window with a NewWindow2 call.
  10. Step 2:  Call fakeModalDialog inside a loop.  Unlike ModalDialog,
  11.          fakeModalDialog returns NULL events.  This makes the loop necessary.
  12. Step 3:  When the dialog should be closed, break out of the loop and close the
  13.          window.  You may wish to use some of fakeModalDialog's data access
  14.          routines before closing the window, since the controls will disappear,
  15.          along with their data, when the window is closed.
  16.  
  17. Using fakeModalDialog is really that simple.
  18.  
  19. Here is some sample c code showing a typical usage:
  20.  
  21.     wptr = NewWindow2(NULL, NULL, NULL, NULL, 2, theWindowID, rWindParam1);
  22.  
  23.     for (;;) {
  24.         ctlID = fakeModalDialog(&event, NULL, NULL, NULL, 0);
  25.         if (ctlID == 1) break;
  26.     }
  27.  
  28.     CloseWindow(wptr);
  29.  
  30.  
  31.  
  32. There are some rules and restrictions when using fakeModalDialog.  (We couldn't
  33. make it too painless, could we?)  These restrictions aren't many, but they are
  34. important.
  35.  
  36. Restriction 1:  Control resource ID's must have bit 31 off.  Bit 31 is reserved
  37.                 by fakeModalDialog.
  38. Restriction 2:  Menu item resource ID's must also have bit 31 off.  This is
  39.                 for the same reason as restriction 1.
  40. Restriction 3:  fakeModalDialog expects extended controls to be used in a
  41.                 window.  While regular controls won't cause fakeModalDialog to
  42.                 explode, they are not handled as well or as efficiently.
  43.  
  44. Those are about the only restrictions to fakeModalDialog.
  45.  
  46.  
  47. What makes fakeModalDialog somewhat complex is the new human interface dialog
  48. type movable/modal dialogs.  These are a new type of animal, and therefore
  49. weren't supported directly by the toolbox.  To fill this gap, fakeModalDialog
  50. has had movable/modal dialog support added.
  51.  
  52. Basically, movable/modal dialogs are a hybrid between modeless dialogs and
  53. modal dialogs.  Movable/modal dialogs have all the properties of modeless
  54. dialogs, except that the movable/modal dialog stays as the top window of
  55. an application.
  56.  
  57. Let's talk about how movable/modal dialog behave on the Mac for a minute.
  58. This will help with the understanding of why fakeModalDialog allows some
  59. of the things that it does.
  60.  
  61. When using MultiFinder on the Mac, you can switch between multiple applications
  62. just by clicking on an application's window (or by other means).  If the
  63. current application has a movable/modal dialog, that dialog must be the
  64. frontmost window for that application.  However, if you click on a window from
  65. another application, that application's windows are brought to the front.  In
  66. this respect, the rule that a movable/modal dialog must be the frontmost window
  67. can be violated.  Other than application switching, however, the rule that a
  68. movable/modal dialog is the frontmost window stands.
  69.  
  70. Now back to the IIGS.
  71.  
  72. The IIGS doesn't have MultiFinder.  It does have desk accessories, however.
  73. Desk accessories are a kind of additional application, and you can switch
  74. between the main application and desk accessories simply by clicking on the
  75. appropriate window.  Desk accessories are as close as the IIGS gets to 
  76. MultiFinder.  Due to this, desk accessory support is a part of fakeModalDialog.
  77.  
  78. Another feature of movable/modal dialogs is that menus are available.  Remember
  79. that movable/modal dialogs are just like modeless dialogs, except that they
  80. stay as the top window.  Modeless dialogs allow menu access, so therefore
  81. movable/modal dialogs should, too.
  82.  
  83. Since menus are available from a movable/modal dialog, the application has to
  84. make sure that the correct menus are and are not available when the
  85. movable/modal dialog is shown.
  86.  
  87.  
  88. This has been a quick introduction to the issues involving movable/modal
  89. dialogs and fakeModalDialog.  The new version of lister uses fakeModalDialog
  90. and movable/modal dialogs extensively.  This sample code should be studied for
  91. more information.
  92.  
  93.